package com.boot2523.control;

import com.boot2523.bean.Dept;
import com.boot2523.bean.Dept2;
import com.boot2523.service.DeptS;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "dept")
public class DeptC {
    @Resource
    public DeptS ds;
    @PostMapping(value = "/insert")
    public int insert(@RequestBody  Dept d){
        return ds.insert(d);
    }
    @RequestMapping(value = "/all")
    public List<Dept> all(){
        return ds.all();
    }
    @GetMapping(value = "/one")
    public Dept one(int id){
        return ds.one(id);
    }
    @DeleteMapping(value = "/del")
    public int del(int id){
        return ds.delete(id);
    }
    @PutMapping(value = "/update")
    public int update(@RequestBody Dept d){
        return  ds.update(d);
    }
    @GetMapping(value = "/page")
    public List<Dept> page(int cur){
        int len=5;
        return  ds.page((cur-1)*len,len);
    }
    @GetMapping(value = "/page2")
    public PageInfo<Dept> page2(int cur){
        int len=5;
        return ds.page2(cur,len);
    }
    @GetMapping(value = "/all2")
    public List<Dept2> all2(){
        return ds.all2();
    }
    @GetMapping(value = "/one2")
    public Dept2 one2(int id){
        return ds.one2(id);
    }
    @GetMapping(value = "/one3")
    public Dept2 one3(String name){
        return ds.one3(name);
    }

}
